package com.neo.web;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.neo.service.ILotteryService;
import com.neo.service.IUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Description:获取数据
 * @Author: xihao.ding
 * @CreateDate: 2018/12/8 14:13
 */
@Controller
public class LotteryController {

    private final static Logger logger = LoggerFactory.getLogger(LotteryController.class);

    @Autowired
    private ILotteryService iLotteryService;

    @RequestMapping("/awards")
    @ResponseBody
    public JSONObject hanlder(String awards , Integer personCount){
        return iLotteryService.begin(awards , personCount);
    }

    @RequestMapping("/save")
    @ResponseBody
    public JSONObject save(String data){
        return iLotteryService.save(data);
    }

    @RequestMapping("/index")
    public String testThymeleaf(ModelMap modelMap) {
        //modelMap.addAllAttributes(iLotteryService.pre());
        return "list";
    }

    @RequestMapping("/show")
    public String showThymeleaf(ModelMap modelMap) {
        modelMap.addAllAttributes(iLotteryService.pre());
        return "show";
    }


}
